﻿using System;

namespace ObjectTest
{
    enum speciality
    {
        informatics,
        mathematics,
        computerScience
    }

    ;
    class Student:IComparable<Student>, ICloneable
    {
        string firstName;
        string secondName;
        string familyName;
        int sSN;
        string adress;
        int mobileTelephone;
        string email;
        int course;
        speciality studentSpeciality;
        string university;
        string faculty;

        public string FirstName
        {
            get
            {
                return firstName;
            }
            set
            {
                firstName = value;
            }
        }

        public string SecondName
        {
            get
            {
                return secondName;
            }
            set
            {
                secondName = value;
            }
        }

        public string FamilyName
        {
            get
            {
                return familyName;
            }
            set
            {
                familyName = value;
            }
        }

        public int SSN
        {
            get
            {
                return sSN;
            }
            set
            {
                sSN = value;
            }
        }

        public string Adress
        {
            get
            {
                return adress;
            }
            set
            {
                adress = value;
            }
        }

        public int MobileTelephone
        {
            get
            {
                return mobileTelephone;
            }
            set
            {
                mobileTelephone = value;
            }
        }

        public string Email
        {
            get
            {
                return email;
            }
            set
            {
                email = value;
            }
        }

        public int Course
        {
            get
            {
                return course;
            }
            set
            {
                course = value;
            }
        }

        public speciality StudentSpeciality
        {
            get
            {
                return studentSpeciality;
            }
            set
            {
                studentSpeciality = value;
            }
        }

        public string University
        {
            get
            {
                return university;
            }
            set
            {
                university = value;
            }
        }

        public string Faculty
        {
            get
            {
                return faculty;
            }
            set
            {
                faculty = value;
            }
        }

        public Student(string firstName, string secondName, string familyName, int sSN, string adress, 
                       int mobileTelephone, string email, int course, speciality studentSpeciality, string university,
                       string faculty)
        {
            this.firstName = firstName;
            this.secondName = secondName;
            this.familyName = familyName;
            this.sSN = sSN;
            this.adress = adress;
            this.mobileTelephone = mobileTelephone;
            this.email = email;
            this.course = course;
            this.studentSpeciality = studentSpeciality;
            this.university = university;
            this.faculty = faculty;
        }

        public override bool Equals(object obj)
        {
            Student other = (Student)obj;
            string firstStudentName = this.firstName + this.secondName + this.familyName;
            string secondStudentName = other.firstName + other.secondName + other.familyName;
            if (firstStudentName != secondStudentName)
            {
                return false;
            }
            if (this.sSN != other.sSN)
            {
                return false;
            }
            if (this.adress != other.adress)
            {
                return false;
            }
            return true;
        }

        public override int GetHashCode()
        {
            int result = course.GetHashCode() + studentSpeciality.GetHashCode() +
                         university.GetHashCode() + faculty.GetHashCode();
            return result;
        }

        public override string ToString()
        {
            string result = String.Format("{0} {1} {2}\n" +
                                          "SSN:{3}\n" +
                                          "adress: {4}\n" +
                                          "telephone: {5} email: {6}\n" +
                                          "course: {7} speciaity: {8}\n" +
                                          "university: {9} faculty: {10}",
                                          firstName, secondName, familyName, sSN, adress, mobileTelephone,
                                          email, course, studentSpeciality, university, faculty);
            return result;
        }

        public static bool operator ==(Student first, Student second)
        {
            return first.Equals(second);
        }

        public static bool operator !=(Student first, Student second)
        {
            return !(first.Equals(second));
        }

        public Student Clone()
        {
            Student newStudent = new Student(this.firstName, this.secondName, this.familyName, this.sSN, this.adress,
                                             this.mobileTelephone, this.email, this.course, this.studentSpeciality, this.university, this.faculty);
            return newStudent;
        }

        public int CompareTo(Student other)
        {
            if (this.firstName != other.firstName)
            {
                return this.firstName.CompareTo(other.firstName);
            }
            return this.sSN.CompareTo(other.sSN);
        }

        object ICloneable.Clone()
        {
            throw new NotImplementedException();
        }
    }
}